//
//  UserConfigurationNSKeyedArchiver.m
//  MISCloud
//
//  Created by goldeneye on 13-8-17.
//  Copyright (c) 2013年 goldeneye. All rights reserved.
//

#import "UserLoginNSCoding.h"

#define kId            @"Id"
#define kusername      @"username"
#define kloginName     @"loginName"
#define kName          @"Name"
#define kCorpId        @"CorpId"
#define kCorpName      @"CorpName"
#define kDeptId        @"DeptId"
#define kDeptName      @"DeptName"
#define kPostId        @"PostId"
#define kPostName      @"PostName"
#define kRoleId        @"RoleId"
#define kRoleName      @"RoleName"
#define kCompanyEmail  @"CompanyEmail"
#define kWhetherOnline @"WhetherOnline"
#define kTelephone     @"Telephone"

@implementation UserLoginNSCoding
@synthesize Id,username,loginName,Name,CorpId,CorpName,DeptId,DeptName,PostId,PostName,RoleId,RoleName,CompanyEmail,WhetherOnline,Telephone;

#pragma mark -
#pragma mark NSCoding

-(void)encodeWithCoder:(NSCoder *)aCoder{//编码
    [aCoder encodeObject:Id forKey:kId];
    [aCoder encodeObject:username forKey:kusername];
    [aCoder encodeObject:loginName forKey:kloginName];
    [aCoder encodeObject:Name forKey:kName];
    [aCoder encodeObject:CorpId forKey:kCorpId];
    [aCoder encodeObject:CorpName forKey:kCorpName];
    [aCoder encodeObject:DeptId forKey:kDeptId];
    [aCoder encodeObject:DeptName forKey:kDeptName];
    [aCoder encodeObject:PostId forKey:kPostId];
    [aCoder encodeObject:PostName forKey:kPostName];
    [aCoder encodeObject:RoleId forKey:kRoleId];
    [aCoder encodeObject:RoleName forKey:kRoleName];
    [aCoder encodeObject:CompanyEmail forKey:kCompanyEmail];
    [aCoder encodeObject:WhetherOnline forKey:kWhetherOnline];
    [aCoder encodeObject:Telephone forKey:kTelephone];
}

-(id)initWithCoder:(NSCoder *)aDecoder{//解码
    self = [super init];
    if(self){
        Id = [aDecoder decodeObjectForKey:kId];
        username = [aDecoder decodeObjectForKey:kusername];
        loginName = [aDecoder decodeObjectForKey:kloginName];
        Name = [aDecoder decodeObjectForKey:kName];
        CorpId = [aDecoder decodeObjectForKey:kCorpId];
        CorpName = [aDecoder decodeObjectForKey:kCorpName];
        DeptId = [aDecoder decodeObjectForKey:kDeptId];
        DeptName = [aDecoder decodeObjectForKey:kDeptName];
        PostId = [aDecoder decodeObjectForKey:kPostId];
        PostName = [aDecoder decodeObjectForKey:kPostName];
        RoleId = [aDecoder decodeObjectForKey:kRoleId];
        RoleName = [aDecoder decodeObjectForKey:kRoleName];
        CompanyEmail = [aDecoder decodeObjectForKey:kCompanyEmail];
        WhetherOnline = [aDecoder decodeObjectForKey:kWhetherOnline];
        Telephone = [aDecoder decodeObjectForKey:kTelephone];
    }
    return self;
}

#pragma mark -
#pragma mark NSCopying

-(id)copyWithZone:(NSZone *)zone{
    UserLoginNSCoding *userInfo = [[[self class]allocWithZone:zone]init];
    userInfo.Id = [self.Id copyWithZone:zone];
    userInfo.username = [self.username copyWithZone:zone];
    userInfo.loginName = [self.loginName copyWithZone:zone];
    userInfo.Name = [self.Name copyWithZone:zone];
    userInfo.CorpId = [self.CorpId copyWithZone:zone];
    userInfo.CorpName = [self.CorpName copyWithZone:zone];
    userInfo.DeptId = [self.DeptId copyWithZone:zone];
    userInfo.DeptName = [self.DeptName copyWithZone:zone];
    userInfo.PostId = [self.PostId copyWithZone:zone];
    userInfo.PostName = [self.PostName copyWithZone:zone];
    userInfo.RoleId = [self.RoleId copyWithZone:zone];
    userInfo.RoleName = [self.RoleName copyWithZone:zone];
    userInfo.CompanyEmail = [self.CompanyEmail copyWithZone:zone];
    userInfo.WhetherOnline = [self.WhetherOnline copyWithZone:zone];
    userInfo.Telephone = [self.Telephone copyWithZone:zone];
    return userInfo;
}


#pragma mark -
#pragma mark to NSDictionary

- (NSDictionary*)dictionary
{
    NSMutableDictionary *mDictionary = [NSMutableDictionary dictionaryWithCapacity:0];
    [mDictionary setObject:Id forKey:@"Id"];
    [mDictionary setObject:username forKey:@"username"];
    [mDictionary setObject:loginName forKey:@"loginName"];
    [mDictionary setObject:Name forKey:@"Name"];
    [mDictionary setObject:CorpId forKey:@"CorpId"];
    [mDictionary setObject:CorpName forKey:@"CorpName"];
    [mDictionary setObject:DeptId forKey:@"DeptId"];
    [mDictionary setObject:DeptName forKey:@"DeptName"];
    [mDictionary setObject:PostId forKey:@"PostId"];
    [mDictionary setObject:PostName forKey:@"PostName"];
    [mDictionary setObject:RoleId forKey:@"RoleId"];
    [mDictionary setObject:RoleName forKey:@"RoleName"];
    [mDictionary setObject:CompanyEmail forKey:@"CompanyEmail"];
    [mDictionary setObject:WhetherOnline forKey:@"WhetherOnline"];
    [mDictionary setObject:Telephone forKey:@"Telephone"];
    
    return mDictionary;
}

@end
